package com.atguigu.gulimall.member.web;

import com.atguigu.common.utils.R;
import com.atguigu.gulimall.member.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

/**
 * 跳转页面
 */
@Controller
@RequestMapping("member")
public class ToPageController {

    @Autowired
    OrderFeignService orderFeignService;

    /**
     * 查询用户所有的订单
     *
     * @return
     */

    @GetMapping("/toOrderList")
    public String toOrderListPage(@RequestParam(value = "paraNum", defaultValue = "1") Integer pageNum, Model model) {
        Map<String, Object> params = new HashMap<>();
        params.put("page", pageNum.toString());
        R res = orderFeignService.getOrderList(params);
        model.addAttribute("orders", res);
        System.out.println(res);
        return "orderList";
    }

}
